package site.assad.dynamicProxy;

/**
 * Author: Al-assad 余林颖
 * E-mail: yulinying_1994@outlook.com
 * Date: 2017/12/4 23:31
 * Description: 记录性能监视信息，结合 PerformanceMonitor 实现为单例模式
 */
public class MethodPerformance {

    private long begin;   //记录测试开始时间戳
    private long end;     //记录测试结束时间戳
    private String method;  //记录测试方法名称

    public MethodPerformance(String method) {
        this.method = method;
        this.begin = System.currentTimeMillis();
    }

    //打印性能测试信息
    public void printPerformance(){
        end = System.currentTimeMillis();
        long elapse = end - begin;
        System.out.println(method+" cost "+ elapse + "millis");
    }

    //重新设定信息
    public void reset(String method){
        this.method = method;
        this.begin = System.currentTimeMillis();

    }
}
